package lab1;
/*  $Id: L4.java
 *  
 *  Copyright 2012, The Johns Hopkins University Whiting School of Engineering
 *  All rights reserved.
 *  This material may be used, modified and reproduced by faculty,
 *  staff, and students of The Johns Hopkins University for instruction, 
 *  evaluation, and grading purposes.  For any other permission, please 
 *  contact The Johns Hopkins University Whiting School of Engineering.
 */
import lab1.mStack.EmptyStackException;
/**
*  Lab1: L4 - Language 4 
*  @date       30JUNE2012
*  @author     Michael W. Mathes
*/
public class L4 {
  public boolean L4(String s){
    mStack st1 = new mStack(s.length());
    mStack st2 = new mStack(s.length());
    mStack err = new mStack(s.length());
    boolean success = false;
    
    for (int i = 0; i < s.length(); i++) {
      char C = s.charAt(i);
           
      //error checking: if it equals something other then A+B push the error stack
      if ( C != 'A' )          // Check A
        if (C != 'B') {        // Check B
          err.push(C);
      }
    
      if (C == 'A'){
          
      }
      
      // B's First
      if (C=='B'){
      }
      
      
      // detect the change from AB-AB (back to A)
      if (i>0 && C=='A'){
          
      }
      
          
      
      
    }//endfor

    
    
    
    
    
    
    
    // Return Block   
    if (st1.isEmpty() && st2.isEmpty()){
      success = true;
    } if (!err.isEmpty()) {
    success =  false;
    }  
      
    return success;  

  }//end L4
}// end class


//
//try {    
//        st1.pop();
//      } catch (EmptyStackException e) {}
